import { DayK, DayKModel } from '../models/DayK';
import db from '../common';

// const EXPRIRES_TIME = 3600;

export default class DayKService {
  hello = () => {
    return new Promise(resolve => resolve('hello User'));
  };
  getPaginDayK = async(ctx: any) => {
    // const ret: any = await db.Find(DayKSchema, conditions, '', {
    //   skip: (pageIndex - 1) * pageSize,
    //   limit: pageSize
    // });
    // ret.total = await db.FindCount(DayKSchema, conditions)
    // return ret;
  };
  addDayK = async(ctx: any) => {
    const dayKInfo: DayK[] = ctx.request.body;
    console.log(dayKInfo);
    const ret = await db.Insert<DayK>(DayKModel, dayKInfo);
    console.log(ret)
    return 'OKK'
  };
  updateDayK = async(ctx: any) => {
    const dayKInfo = ctx.request.body;
    console.log(dayKInfo);
    const conditions = {
      id: dayKInfo.id
    }
    const ret = await db.Update(DayKModel, conditions, dayKInfo);
    return ret;
  };
  deleteDayK = async(ctx: any) => {
    const dayKInfo = ctx.request.body.dayKInfo;
    const conditions = {
      id: {
        $in: dayKInfo
      }
    }
    const ret = await db.DeleteOne(DayKModel, conditions);
    return ret;
  }
}
